﻿/// <reference path="typings/angularjs/angular.d.ts" />
/* tslint:disable:jsdoc-format */
// warning: Generated code! Do not change!
module AppXXX {
    "use strict";
    export class AjaxHelper {
        private $http: angular.IHttpService;

        constructor(public baseUrl: string) {
            this.$http = angular.injector(["ng"]).get("$http");

            if (baseUrl.match(/\/$/)) {
                baseUrl += "/";
            }
        }

        request<T>(url: string, httpVerb: string, data?: any): angular.IPromise<T> {
            var config: ng.IRequestConfig = {
                url: this.baseUrl + url,
                cache: false,
                method: httpVerb
            };

            if (data) {
                config.data = data;
            }
            return this.$http(config).then((response: angular.IHttpPromiseCallbackArg<{}>) => {
                return response.data;
            });
        }
    }

    export class CustomerProxy {
        constructor(public baseUrl: string = "") { }

        Get(): ng.IPromise<Array<Models.ICustomer>> {
            return new AjaxHelper(this.baseUrl).request<Array<Models.ICustomer>>("api/customer/get", "GET");
        }
    }
} 